//
//  HJSettlementAdditionalItemsView.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/5/16.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJSettlementAdditionalItemsView.h"

#import "HJSettlementAdditionalItemsViewCell.h"

@interface HJSettlementAdditionalItemsView()<UITableViewDelegate,UITableViewDataSource>
/**
 table
 */
@property(nonatomic,strong)UITableView*tableView;
/**
 标题视图
 */
@property(nonatomic,strong)HJCommonTableHeaderView*headerView;

@end
@implementation HJSettlementAdditionalItemsView
-(UITableView *)tableView
{
    if (!_tableView) {
        _tableView=[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        _tableView.tableFooterView=[UIView new];
        _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        [self addSubview:_tableView];
        WEAKSELF;
        [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(weakSelf);
            make.top.mas_equalTo(weakSelf.headerView.mas_bottom);
            make.bottom.mas_equalTo(weakSelf);
        }];
        
        //        _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        //
        //            weakSelf.page = 1;
        //            [weakSelf getData];
        //        }];
        //        _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        //            [weakSelf getData];
        //        }];
    }
    return _tableView;
}
InitFrameM
-(void)setUI{
    WEAKSELF;
    //table头部
    NSMutableArray *labelMutabelArray = [[NSMutableArray alloc]initWithObjects:@"序号",@"项目代码",@"项目名称",@"附加项目费",@"折扣率",@"优惠金额",nil];
    HJCommonTableHeaderView*headerView=[[HJCommonTableHeaderView alloc]init];
    headerView.titleAry=[labelMutabelArray copy];
    headerView.backgroundColor=[UIColor grayColor];
    headerView.titleColor=[UIColor blackColor];
    self.headerView=headerView;
    [self addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(weakSelf);
        make.height.mas_equalTo(45);
    }];
}
-(void)setADDITEM:(NSArray<HJRepairSettlementAdditemModel *> *)ADDITEM
{
    _ADDITEM=ADDITEM;
    [self.tableView reloadData];
}
#pragma mark --UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    //
    return self.ADDITEM.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HJSettlementAdditionalItemsViewCell*cell=[HJSettlementAdditionalItemsViewCell cellWithTable:tableView];
    cell.repairSettlementAdditemModel=self.ADDITEM[indexPath.row];
     cell.indePath=indexPath;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row%2 == 1)
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:226.00/255 green:226.00/255 blue:226.00/255 alpha:1];
    }
    else
    {
        cell.backgroundColor = [UIColor whiteColor];
    }
}


@end
